"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const taro_1 = require("@tarojs/taro");
const components_1 = require("@tarojs/components");
const taro_ui_1 = require("taro-ui");
const prop_types_1 = require("prop-types");
require("./index.scss");
const IMAGE_PREFIX = 'https://clover-mini-program.oss-cn-beijing.aliyuncs.com/';
class XGood extends taro_1.Component {
    constructor() {
        super(...arguments);
        this.state = {
            current: 0
        };
        this.navigateToMiniProgram = appId => {
            taro_1.default.navigateToMiniProgram({ appId }).then(res => {
                console.log(res, '小程序跳转成功');
            }).catch(e => taro_1.default.showToast({ title: '请在后台以及公众号正确绑定小程序 ID', icon: 'none' }));
        };
        this.onSwiperChange = e => {
            this.setState(state => (Object.assign({}, state, { current: e.detail.current })));
        };
    }
    render() {
        return (<components_1.View className='good'>
        <components_1.Swiper className='banner' indicatorColor='#eee' indicatorActiveColor='#FD5543' vertical={false} circular indicatorDots autoplay duration={300} onChange={this.onSwiperChange}>
          {this.props.data.GoodsPrizes.map(item => (<components_1.SwiperItem key={item.id}>
                <components_1.Image src={IMAGE_PREFIX + item.cover} className='image' mode='widthFix'/>
              </components_1.SwiperItem>))}
        </components_1.Swiper>

        <components_1.View className='profile-title'>
          <components_1.View className='title'>
            <components_1.Text className='text'>{this.props.data.GoodsPrizes && this.props.data.GoodsPrizes[this.state.current].title}</components_1.Text>
          </components_1.View>
          <components_1.View className='brief'>
            <components_1.Text className='text'>{this.props.data.type === 0 ? `参与人数满${this.props.data.number}自动开奖` : this.props.data.type === 1 ? `${this.props.data.endAt}自动开奖` : null}</components_1.Text>
          </components_1.View>
        </components_1.View>

        <taro_ui_1.AtList hasBorder={true}>
          <taro_ui_1.AtListItem title='赞助商' extraText={this.props.data.sponsor} arrow='right' extraThumb='http://img10.360buyimg.com/jdphoto/s72x72_jfs/t5872/209/5240187906/2872/8fa98cd/595c3b2aN4155b931.png' onClick={this.navigateToMiniProgram.bind(this, 'appId')}/>
        </taro_ui_1.AtList>
      </components_1.View>);
    }
}
XGood.propTypes = {
    data: prop_types_1.default.object,
    GoodsPrizes: prop_types_1.default.array
};
XGood.defaultProps = {
    data: {},
    GoodsPrizes: [],
};
exports.default = XGood;
//# sourceMappingURL=index.jsx.map